/*
 * @Author: wuqingchun
 * @Date: 2024-09-27 08:50:45
 * @Description: 
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-09-29 17:36:59
 */
#ifndef __CHAT_CLIENT_H__
#define __CHAT_CLIENT_H__

#include <cstddef>
#include "chat_session.h"

typedef enum tagChatClientCommand
{
    CHAT_CLIENT_CMD_HELP,
    CHAT_CLIENT_CMD_LOGIN,
    CHAT_CLIENT_CMD_LOGOUT,
    CHAT_CLIENT_CMD_REGISTER,
    CHAT_CLIENT_CMD_EXIT,
    CHAT_CLIENT_CMD_MAX,
}CHAT_CLIENT_COMMAND_E;

class CChatClient
{
public:
    CChatClient(const char* pcServerHost, uint16_t usPort);
    ~CChatClient();

    void Run();

private:
    void __WaitInput(const char* pcPrompt, char* pcBuff, size_t ulBufLen);
    CHAT_CLIENT_COMMAND_E __GetCommand();
    void __DispatchCommand(CHAT_CLIENT_COMMAND_E enCmd);
private:
    CChatSession m_objSession;

    volatile bool m_bRunning = false;
};

#endif //__CHAT_CLIENT_H__